package com.Txunda.fxw.ui.adapter;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;

import com.Txunda.fxw.R;
import com.bumptech.glide.Glide;
import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ViewInject;

import java.util.ArrayList;
import java.util.Map;

/**
 * 创建人： Nine tails fox
 * 创建时间： 2019/6/18
 * 功能描述：
 * 联系方式：1037438704@qq.com
 *
 * @author NineTailDemonFox
 */

public class LawMyAdp extends BaseAdapter {


    LawMyAdp.MyViewHolder vh;
    private Context context;
    private ArrayList<Map<String, String>> list_data = new ArrayList<>();

    public LawMyAdp(Context context, ArrayList<Map<String, String>> list_data) {
        this.context = context;
        this.list_data = list_data;
    }

    public void addList(ArrayList<Map<String, String>> list_data) {
        this.list_data = list_data;
    }

    @Override
    public int getCount() {
        return list_data.size();
    }

    @Override
    public Map<String, String> getItem(int position) {
        return list_data.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.item_company_list, parent, false);
            vh = new MyViewHolder();
            ViewUtils.inject(vh, convertView);
            convertView.setTag(vh);
        } else {
            vh = (MyViewHolder) convertView.getTag();
        }
        Glide.with(context).load(list_data.get(position).get("cover_pic")).into(vh.item_company_img);
        vh.item_company_title.setText(list_data.get(position).get("name"));

        return convertView;
    }

    class MyViewHolder {
        @ViewInject(R.id.compmay_frame_item)
        private FrameLayout compmay_frame_item;
        @ViewInject(R.id.item_company_img)
        private ImageView item_company_img;
        @ViewInject(R.id.item_company_title)
        private TextView item_company_title;
        @ViewInject(R.id.item_company_distance)
        private TextView item_company_distance;
        @ViewInject(R.id.item_company_address)
        private TextView item_company_address;
    }


}
